package com.zoweunion.mechanic.util.mq;

import com.zoweunion.mechanic.plugins.mq.RabbitmqConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class RabbitmqUtil {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送实时通讯报文，前端接收
     * @param content
     */
    public void sendMessage(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_REAL_MESSAGE, content);
    }

    /**
     * 发送实时数据到APP-PC后台做提醒
     * @param content
     */
    public void sendRealDataToAPPMessage(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_REAL_REMIND_ALARM_MESSAGE, content);
    }


    /**
     * 发送日志记录到logserver
     * @param content
     */
    public void sendLogServerMessage(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_LOG_SERVER_MESSAGE, content);
    }

    /**
     * 发送设备实时变量
     * @param content
     */
    public void sendData(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_REAL_DATA, content);
    }

    public void sendEarlyWarn(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_EARLY_WARN, content);
    }
    public void sendcarOnline(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_CAR_ONLINE, content);
    }
    public void sendGatewayOnline(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_GATEWAY_ONLINE, content);
    }
    public void sendMysqlCount(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_MYSQL_COUNT, content);
    }
    public void sendRedisKyeCount(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_REDISKEY_COUNT, content);
    }
    public void sendMemoryOccupy(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_MEMORY_OCCUPY, content);
    }
    public void sendCpuOccupy(String content){
        rabbitTemplate.convertAndSend(RabbitmqConfig.IOT_SERVER_TOPIC_EXCHANGE, RabbitmqConfig.ROUTE_KEY_CPU_OCCUPY, content);
    }
}
